<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>

<@header title="角色列表">
    <link href="${ctx}/resource/common/css/pagination.css" rel="stylesheet">
    <script src="${ctx}/resource/common/js/pagination.js"></script>
</@header>

<@body>
    <h2 class="module-title">角色管理</h2>

    <div class="alert alert-primary" role="alert">
        <form class="form-inline form-margin" action="${ctx}/role/list">
            <div class="form-group mb-2">
                <label for="name" class="ml-2">角色名称：</label>
                <input type="text" class="form-control" id="name" name="name" value="${role.name}" style="max-width: 150px">
            </div>
            <div class="form-group mb-2">
                <label for="description" class="ml-2">描述：</label>
                <input type="text" class="form-control" id="description" name="description" value="${role.description}" style="max-width: 150px">
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="status" class="ml-2">状态：</label>
                <select class="form-control" name="status" id="status">
                    <option value="" >请选择</option>
                    <#list statusValues as status>
                        <option value="${status}" <#if status == role.status>selected</#if>>${status.desc}</option>
                    </#list>
                </select>
            </div>

            <div class="form-group mx-sm-3 mb-2">
                <button type="submit" class="btn btn-primary">查询</button>
            </div>

            <@shiro.hasPermission name="role:toAdd">
            <div class="form-group mx-sm-3 mb-2" style="float:right">
                <span style="float:left"><a href="${ctx}/role/toAdd">添加数据</a></span>
            </div>
            </@shiro.hasPermission>
        </form>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
                <th>主键</th>
                <th>角色名称</th>
                <th>描述</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </thead>
            <tbody>
            <#list roles.beans as role>
                <tr>
                    <th>${role.id!}</th>
                    <th>${role.name!}</th>
                    <th>${role.description!}</th>
                    <th>
                        <#if role.status == 'enable'><h5><span class="badge badge-success">${role.status.desc!}</span></h5></#if>
                        <#if role.status == 'disable'><h5><span class="badge badge-secondary">${role.status.desc!}</span></h5></#if>
                    </th>
                    <th>${(role.createTime?string('yyyy-MM-dd hh:mm:ss'))!} </th>
                    <th>${(role.updateTime?string('yyyy-MM-dd hh:mm:ss'))!} </th>
                    <th><@shiro.hasPermission name="role:view"><a class="btn btn-primary btn-sm" href="${ctx}/role/view/${role.id?c}" role="button" aria-pressed="true">详情</a></@shiro.hasPermission>
                        <@shiro.hasPermission name="role:edit"><a class="btn btn-info btn-sm" href="${ctx}/role/toEdit/${role.id?c}" role="button" aria-pressed="true">编辑</a></@shiro.hasPermission>
                        <@shiro.hasPermission name="manager:roleAuthorize"><a class="btn btn-warning btn-sm" href="${ctx}/manager/roleAuthorize/${role.id?c}" role="button"
                                                                              aria-pressed="true">分配权限</a></@shiro.hasPermission>
                        <@shiro.hasPermission name="manager:roleAuthorize_view"><a class="btn btn-info btn-sm" href="${ctx}/manager/roleAuthorizeView/${role.id?c}" role="button"
                                                                                   aria-pressed="true">查看权限</a></@shiro.hasPermission>

                    </th>
                </tr>
            </#list>
            </tbody>
        </table>

        <@Pagination.pagination formId="roleForm"
            pageNo=roles.pageNo
            pageTotal=roles.pageTotal
            total=roles.total
            pageSize=roles.pageSize
            action="${ctx}/role/list">
            <input type="hidden" name="name" value="${role.name}"/>
            <input type="hidden" name="module.id" value="${role.module.id}"/>
            <input type="hidden" name="description" value="${role.description}"/>
            <input type="hidden" name="status" value="${role.status}"/>
        </@Pagination.pagination>
    </div>
</@body>

<@footer>

</@footer>